import java.util.ArrayList;
import java.util.Arrays;

public class Mystack {
    private int[] elem;
    //代表下表个数
    private int usedsize;
    private static final int DEFAUT_CAPCITY=10;
    public Mystack(){
        //初始化栈
        this.elem=new int[DEFAUT_CAPCITY];
    }
    //将数字放入数组

    public void push(int val){
        //

        this.elem= Arrays.copyOf(elem,2*elem.length);
        elem[usedsize]=val;
        usedsize++;

    }


    public boolean isfull(){
        return usedsize==elem.length;
    }
    public int peek(){
        if (isempty()){
            throw new EmptyException();
        }
        return elem[usedsize-1];
    }
    public int pop(){
        if (isempty()){
            throw new EmptyException();

        }
        else {
            int oldVal=elem[usedsize-1];
            usedsize--;

            return oldVal;
        }
    }
    //判断是不是空的
    public boolean isempty(){
        return usedsize==0;

    }
}

